//
//  MainTabBarVC.swift
//  SinaWeibo
//
//  Created by bot on 16/5/12.
//  Copyright © 2016年 bot. All rights reserved.
//

import UIKit

class MainTabBarVC: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setValue(MainTabBar(), forKey: "tabBar")
        
        
        addChildViewControllers()
    }
    
    private func  addChildViewControllers () {
        
         addChildViewController(HomeTableVC(), image: "tabbar_home",selectedImg: "tabbar_home_highlighted", title: "首页")
         addChildViewController(MessageTableVC(), image: "tabbar_message_center",selectedImg: "tabbar_message_center_highlighted", title: "消息")
         addChildViewController(DiscoverTableVC(), image: "tabbar_discover",selectedImg: "tabbar_discover_highlighted", title: "发现")
         addChildViewController(ProfileTableVC(), image: "tabbar_profile",selectedImg: "tabbar_profile_highlighted", title: "我")
        
    
        
    
    }

   
    private func addChildViewController(vc: UIViewController, image: String, selectedImg: String, title: String) {
    
    let nav = UINavigationController(rootViewController: vc)
    
    vc.title = title
    vc.tabBarItem.image = UIImage(named: image)
    vc.tabBarItem.selectedImage = UIImage(named: selectedImg)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
//    tabBar.tintColor = UIColor.orangeColor()
        
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
    
    
    addChildViewController(nav)
        
        
       
        
    }
    

  

}
